<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作业3答案</title>
</head>
<body>
<table border="1" style="border-collapse: collapse;">
    <tr>
        <th><input type="checkbox" id="selectAll" onclick="toggleAll()"></th>
        <th>编号</th>
        <th>图片</th>
        <th>型号</th>
        <th>主标题</th>
        <th>规格</th>
        <th>单价</th>
        <th>操作</th>
    </tr>
    <tr>
        <td><input type="checkbox" name="item" value="1" class="itemCheckbox"></td>
        <td style="text-align: center">1</td>
        <td><img src="1.jpg" alt="" width="75"></td>
        <td>AppleMacBoo...</td>
        <td>AppleMacBookAir...</td>
        <td>双核i5...</td>
        <td>￥6999.00</td>
        <td><a href="1">详情</a>&nbsp;<a href="1">修改</a>&nbsp;<a href="1"> 删除</a></td>
    </tr>
    <tr>
        <td><input type="checkbox" name="item" value="2" class="itemCheckbox"></td>
        <td style="text-align: center">2</td>
        <td><img src="2.jpg" alt="" width="75"></td>
        <td>戴尔灵越15PR-...</td>
        <td>戴尔DELL灵越游匣15...</td>
        <td>宗师版...</td>
        <td>￥5999.00</td>
        <td><a href="1">详情</a>&nbsp;<a href="1">修改</a>&nbsp;<a href="1"> 删除</a></td>
    </tr>
    <tr>
        <td><input type="checkbox" name="item" value="3" class="itemCheckbox"></td>
        <td style="text-align: center">3</td>
        <td><img src="3.jpg" alt="" width="75"></td>
        <td>旗舰版小米Air...</td>
        <td>小米(MI)Air 13.3英寸...</td>
        <td>13英寸...</td>
        <td>￥4999.00</td>
        <td><a href="1">详情</a>&nbsp;<a href="1">修改</a>&nbsp;<a href="1"> 删除</a></td>
    </tr>
    <tr>
        <td><input type="checkbox" name="item" value="4" class="itemCheckbox"></td>
        <td style="text-align: center">4</td>
        <td><img src="4.jpg" alt="" width="75"></td>
        <td>神舟战神Z77...</td>
        <td>神舟(HASEE)战神Z77...</td>
        <td>战神Z7...</td>
        <td>￥5499.00</td>
        <td><a href="1">详情</a>&nbsp;<a href="1">修改</a>&nbsp;<a href="1"> 删除</a></td>
    </tr>
    <tr>
        <td><input type="checkbox" name="item" value="5" class="itemCheckbox"></td>
        <td style="text-align: center">5</td>
        <td><img src="5.jpg" alt="" width="75"></td>
        <td>ThinkPadE4...</td>
        <td>联想(ThinkPad)轻...</td>
        <td>E4700...</td>
        <td>￥4699.00</td>
        <td><a href="1">详情</a>&nbsp;<a href="1">修改</a>&nbsp;<a href="1"> 删除</a></td>
    </tr>
    <tr>
        <td><input type="checkbox" name="item" value="6" class="itemCheckbox"></td>
        <td style="text-align: center">6</td>
        <td><img src="6.jpg" alt="" width="75"></td>
        <td>戴尔燃7000...</td>
        <td>戴尔DELL灵越燃700...</td>
        <td>溢彩金...</td>
        <td>￥6599.00</td>
        <td><a href="1">详情</a>&nbsp;<a href="1">修改</a>&nbsp;<a href="1" > 删除</a></td>
    </tr>
</table>

<script>
    function toggleAll() {
        // 获取全选checkbox的状态
        const selectAllCheckbox = document.getElementById('selectAll');
        // 获取所有item的checkbox
        const itemCheckboxes = document.querySelectorAll('.itemCheckbox');

        // 将所有item的checkbox设置为与全选checkbox相同的状态
        itemCheckboxes.forEach(checkbox => {
            checkbox.checked = selectAllCheckbox.checked;
        });
    }
</script>
</body>
</html>
